<script type="text/ecmascript-6">
  import Navbar from '../../components/base/navbar.vue';
  export default{
      name:"coach_memeber",
      components:{
          Navbar
      },
      data(){
          return{
              tabList:[
                {
                    id:"tab1",
                    name:"基本资料"
                },
                {
                    id:"tab2",
                    name:"参加过的野练"
                }
              ],
              heights:"100%",
              isDrag:false,
              page: 0,
              hasMore: true,
              myID: this.$route.params.id,
              user: {
                group: {
                  grade: ''
                }
              }
          }
      },
    methods:{
        loadMore(){
          if(!this.hasMore){
              return this.$emit("on");
          }
          var page =this.page+1;
          this.$store.dispatch("queryMemberDetail",{id:this.myID,page:page});
        },
        refresh(){
          this.$store.dispatch("queryMemberDetail",{id:this.myID});
        },
        memberComplete(user){
            this.user=user;
            this.$refs.pulldown.onLoadOff();
        },
        pageLoaded(success,page){
            if(success){
                this.hasMore = page.current_page < page.total_pages;
                this.page =page.current_page;
            }

        },
        done(){
          this.$nextTick(() => {
            this.$refs.pulldown.onLoadOff();
          })
        },
        jump(id){
          this.$router.push({ name: 'activity_detail', params: {id: id, entrance: 'registration'} });
        }
    },
    created(){
        EventBus.$on("member-complete",this.memberComplete);
        EventBus.$on("page-loaded",this.pageLoaded);
        this.$on("done",this.done);
        this.$store.dispatch("queryMemberDetail",{id:this.myID});
    },
    beforeDestroy(){
      EventBus.$off("member-complete");
      EventBus.$off("page-loaded");
    },
    computed:{
        detail:{
            get(){
                return this.$store.getters.getMemberDetail
            }
        }
    }
  }
</script>
